package com.wnxy.sddfp.client.bank.fallback;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wnxy.sddfp.client.bank.TradeLogApi;
import com.wnxy.sddfp.common.model.dto.bank.BankCardAddDTO;
import com.wnxy.sddfp.common.model.dto.bank.SignatureDto;
import com.wnxy.sddfp.common.model.vo.borrow.BorrowSyncRecordVo;
import com.wnxy.sddfp.common.result.Result;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2024 -04-19
 * @desc
 */
@Component
public class TradeLogApiFallBack implements TradeLogApi {
    @Override
    public SignatureDto proxyBindCardLog(BankCardAddDTO bankCardAddDTO) {
        SignatureDto signatureDto = new SignatureDto();
        signatureDto.setBankUrl("http://localhost:5600/bank/user");
        signatureDto.setPlatformNo("SDDFQ + 服务降级");
        //  请求数据
        try {
            signatureDto.setReqData(new ObjectMapper().writeValueAsString(bankCardAddDTO));
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
        signatureDto.setReqCode(bankCardAddDTO.getReqCode());

        return signatureDto;
    }

    @Override
    public Result syncBorrowRecord(BorrowSyncRecordVo borrowSyncRecordVo) {
        return Result.fail("进行了服务降级 远程调用失败...");
    }
}
